
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>up2</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/Huploadify.css">

</head>
<body>
<input type="" name="xx">
<div class="imageUpload"></div>
<div class="preview"></div>
</body>
<script src="${pageContext.request.contextPath}/resources/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/js/jquery.Huploadify.js"></script>

<script>
    $('.imageUpload').each(function(){
        var aa = function(obj){
            obj.Huploadify({
                auto:true,
                fileTypeExts:'*.jpg;*.png;',
                multi:true,
                //formData:{name:'image0'},
                fileSizeLimit:9999,
                showUploadedPercent:true,//是否实时显示上传的百分比，如20%
                showUploadedSize:true,
                removeTimeout:9999999,
                uploader:'${pageContext.request.contextPath}/upload2',
                onUploadComplete:function(file,data,response){
                    //获得回填数据
                    data_json= JSON.parse(data)
                    src = "${pageContext.request.contextPath}"+data_json.path;
                    //此处obj为上传控件  ,代表每个imageUpload
                    //回填表单
                    obj.prev().val(data_json.path);
                    //填充预览图
                    obj.next().html("<img src='"+src+"' style='height:250px'/>");
                    setTimeout(function(){
                        obj.find('.uploadify-queue-item').html('');
                    },1000);
                },
                onUploadSuccess: function (){

                }
            });
        }
        aa($(this));
    });
</script>
</html>

